package com.ymt.fmd.platform.service;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Context;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ymt.fmd.platform.dao.mysql.PPopupPageMapper;
import com.ymt.fmd.util.DhxUtil;

@Service
public class PopupPageService {

	@Autowired
	private PPopupPageMapper pppDao;
	
	/**
	 * 请求数据
	 */
	@Context
	private HttpServletRequest request;
	
	public String findPopupUrl(String tenantId, 
			int fromRow, int toRow,
			int timezoneOffset, 
			String lang, 
			String ordercolumns){
		
		int fInd = fromRow - 1;
		int rows = toRow - fromRow + 1;
		String orderby = DhxUtil.parseGridOrderBy(ordercolumns);
		
		List<Map<String,?>> list = pppDao.findAll(tenantId, orderby, fInd, rows);
		int cnt = pppDao.findAllCount(tenantId);
		String[] cols = new String[]{"id","name","url"};
		String rtn= DhxUtil.toGridJsonStr(list,cols, fromRow, cnt, timezoneOffset, lang);
		return rtn;
	}
}
